package com.vitabuybuy.tv.network

import com.library.common.net.NetUrl
import com.vitabuybuy.tv.dto.CoinRecordDto
import com.vitabuybuy.tv.dto.RechargeDto
import rxhttp.IAwait
import rxhttp.wrapper.param.RxHttp
import rxhttp.wrapper.param.toResponse

/**
 * 作者：SimGa
 * 日期：2020/12/3
 * 时间：17:04
 * 包名：com.vitabuybuy.tv.network
 */
object CoinRepository {

    fun getMyCoin(): IAwait<Int> {
        return RxHttp.postJson(NetUrl.api_my_coin).toResponse()
    }

    fun getRechargeList(): IAwait<MutableList<RechargeDto>> {
        return RxHttp.postJson(NetUrl.api_coin_list).addAll("{}").toResponse()
    }

    fun rechargeCoin(id: Int?, paymentMethod: String): IAwait<String> {
        return RxHttp.postJson(NetUrl.api_coin_recharge)
            .add("id",id)
            .add("paymentMethod",paymentMethod)
            .toResponse()
    }

    fun getCoinRecord(
        pageNumber: Int,
        pageSize: Int
    ): IAwait<MutableList<CoinRecordDto>> {
        return RxHttp.postJson(NetUrl.api_gold_record)
            .add("pageable",mapOf(
                Pair("page", pageNumber),
                Pair("size", pageSize),
                Pair("desc", "id")
            ))
            .toResponse()
    }
}